package com.css.openapi.filter;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;

import com.css.common.core.constant.Result;
import com.css.common.core.constant.SsoConstants;
import com.css.common.core.session.SessionManager;
import com.css.common.core.session.SessionUtils;
import com.css.common.core.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

@Slf4j
public class SecurityFilter extends OncePerRequestFilter {


    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
            throws IOException, ServletException {
        request = new AuthRequestWrapper(request);
        filterChain.doFilter(request, response);
    }

    @Override
    public void destroy() {
        SessionManager.get().clear();
    }

}
